import request from "@/utils/request";
// 上传文件
export function uploads(
  data: any,
  callback?: Function
): Promise<IResponse<FileInfos>> {
  var formData = new FormData();

  for (let key in data) {
    formData.append(key, data[key]);
  }
  if (!formData.has("path")) {
    formData.append("path", "/files");
  }
  return request({
    url: "/upload/",
    method: "post",
    headers: {
      "Content-type": "multipart/form-data",
    },
    timeout: 100000,
    data: formData,
    onUploadProgress: (progressEvent) => callback && callback(progressEvent), //上传进度
  });
}
